package com.liu.service;

import com.liu.dao.BookDao;
import com.liu.pojo.Book;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookService {
@Autowired
BookDao bookDao;

public void addBook(Book book){
    bookDao.save(book);
}

public Page<Book> getBookByPage(Pageable pageable){
    return bookDao.findAll(pageable);
}

public List<Book> getBookByAuthorStartingWith(String author){
    return  bookDao.getBooksByAuthorStartingWith(author);
}

public List<Book> getBookByPriceGreaterThan(Float price){
    return bookDao.getBooksByPriceGreaterThan(price);
}
public Book getMaxIDBook(){
    return bookDao.getMaxIdBook();
}

public List<Book> getBookByIdAndName(String name,Integer id){
    return bookDao.getBookByIdAndAuthor(name,id);
}

public List<Book> getBookByIdAndAuthor(String author,Integer id){
    return bookDao.getBookByIdAndAuthor(author,id);
}









}







